//
//  CXBarcodeViewController.m
//  微博
//
//  Created by c_xie on 15-4-10.
//  Copyright (c) 2015年 c_xie. All rights reserved.
//

#import "CXBarcodeViewController.h"

@interface CXBarcodeViewController ()
- (IBAction)close:(id)sender;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topCons;
@property (nonatomic,strong) CADisplayLink *link;

@end

@implementation CXBarcodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.link = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
}

- (void)update
{
    self.topCons.constant -= 2;
    if (self.topCons.constant <= -170) {
        self.topCons.constant = 170;
    }
}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.link removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
}

- (IBAction)close:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
